import request from '../utils/request';
import host, { filter } from '../utils/constant';


export async function list(params) {
  const { articlePageNum, articlePageSize, sorted, articleKeywords, baiJiaId } = params;
  const requestUrl = `${host}/article/list?
  pageSize=${articlePageSize}
  &pageNum=${articlePageNum}
  &sorted=${filter(sorted)}
  &keywords=${filter(articleKeywords)}
  &baiJiaId=${filter(baiJiaId)}`;
  return request(requestUrl);
}

export async function search(params){
  const { articlePageNum, articlePageSize, articleKeywords, category, sorted } = params;
  const requestUrl = `${host}/article/search?
  pageSize=${articlePageSize}
  &pageNum=${articlePageNum}
  &keywords=${filter(articleKeywords)}
  &category=${filter(category)}
  &sorted=${filter(sorted)}`;
  return request(requestUrl);
}

export async function total(){
  const requestUrl = `${host}/article/total`;
  return request(requestUrl);
}
